package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.StockInfoGlobalEm;
import com.ruoyi.system.service.IStockInfoGlobalEmService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 全球财经快讯Controller
 * 
 * @author leng.xz
 * @date 2024-05-18
 */
@Controller
@RequestMapping("/system/InfoGlobalEm")
public class StockInfoGlobalEmController extends BaseController
{
    private String prefix = "system/InfoGlobalEm";

    @Autowired
    private IStockInfoGlobalEmService stockInfoGlobalEmService;

    @RequiresPermissions("system:InfoGlobalEm:view")
    @GetMapping()
    public String InfoGlobalEm()
    {
        return prefix + "/InfoGlobalEm";
    }

    /**
     * 查询全球财经快讯列表
     */
    @RequiresPermissions("system:InfoGlobalEm:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(StockInfoGlobalEm stockInfoGlobalEm)
    {
        startPage();
        List<StockInfoGlobalEm> list = stockInfoGlobalEmService.selectStockInfoGlobalEmList(stockInfoGlobalEm);
        return getDataTable(list);
    }

    /**
     * 导出全球财经快讯列表
     */
    @RequiresPermissions("system:InfoGlobalEm:export")
    @Log(title = "全球财经快讯", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(StockInfoGlobalEm stockInfoGlobalEm)
    {
        List<StockInfoGlobalEm> list = stockInfoGlobalEmService.selectStockInfoGlobalEmList(stockInfoGlobalEm);
        ExcelUtil<StockInfoGlobalEm> util = new ExcelUtil<StockInfoGlobalEm>(StockInfoGlobalEm.class);
        return util.exportExcel(list, "InfoGlobalEm");
    }

    /**
     * 新增全球财经快讯
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存全球财经快讯
     */
    @RequiresPermissions("system:InfoGlobalEm:add")
    @Log(title = "全球财经快讯", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(StockInfoGlobalEm stockInfoGlobalEm)
    {
        return toAjax(stockInfoGlobalEmService.insertStockInfoGlobalEm(stockInfoGlobalEm));
    }

    /**
     * 修改全球财经快讯
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        StockInfoGlobalEm stockInfoGlobalEm = stockInfoGlobalEmService.selectStockInfoGlobalEmById(id);
        mmap.put("stockInfoGlobalEm", stockInfoGlobalEm);
        return prefix + "/edit";
    }

    /**
     * 修改保存全球财经快讯
     */
    @RequiresPermissions("system:InfoGlobalEm:edit")
    @Log(title = "全球财经快讯", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(StockInfoGlobalEm stockInfoGlobalEm)
    {
        return toAjax(stockInfoGlobalEmService.updateStockInfoGlobalEm(stockInfoGlobalEm));
    }

    /**
     * 删除全球财经快讯
     */
    @RequiresPermissions("system:InfoGlobalEm:remove")
    @Log(title = "全球财经快讯", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(stockInfoGlobalEmService.deleteStockInfoGlobalEmByIds(ids));
    }
}
